package protocol.SZ_2021;

public class Handle2021SZ85 implements IHandle2021SZ {
    @Override
    public String handle(SZ_2021Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x00:
                return handle8500(cmd);
            default:
                return "深标:未匹配的命令字"+(cmd.readOrder()+","+cmd.readSubOrder());
        }
    }

    private String handle8500(SZ_2021Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:车辆控制");
        builder.append("\r\n");

        final int type = cmd.readInt(1);
        int order = cmd.readInt(1);
        switch (type){
            case 0:
                builder.append(order == 0?"恢复车辆油路":"断开车辆油路");
                break;
            case 1:
                builder.append(order == 0?"恢复车辆电路":"断开车辆电路");
                break;
            case 2:
                builder.append(order == 0?"车门解锁":"车门加锁");
                break;
            case 3:
                builder.append(order == 0?"智能服务终端解锁":"智能服务终端锁定");
                break;
            case 4:
                builder.append(order == 0?"计程计价装置解锁":"计程计价装置锁定");
                builder.append("\r\n");
                builder.append("拓展数据:"+cmd.readBCD(16));
                break;
        }
        builder.append("\r\n");
        return builder.toString();
    }

}
